/*
 * @Date: 2021-09-12 19:21:05
 * @Author: Acckno1
 * @LastEditTime: 2021-09-12 19:23:47
 * @Description: 
 */
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

const int N = 1010, M = 31 * 1440 + 10;

struct Record{
    int minutes;
    string state;
    string format_time;
    
//     bool operator < (const Record & t) const {
//         return minutes < t.minutes;
//     }
};

int n;
int cost[24];
double sum[M]; // 从当月1号00:00开始到每个时刻所花费的钱数之和
map<string, vector<Record>> records;

bool cmp(const Record& a, const Record& b) {
    return a.minutes < b.minutes;
}

int main () {
    for (int i = 0; i < 24; i ++ ) cin >> cost[i];
    for (int i = 1; i <= M; i ++ ) sum[i] = sum[i - 1] + cost[(i - 1) % 1440 / 60] / 100.0;
    
    cin >> n;
    char name[25], state[10], format_time[10];
    int month, day, hour, minute;
    for (int i = 0; i < n; i ++ ) {
        scanf("%s %d:%d:%d:%d %s", name, &month, &day, &hour, &minute, state);
        sprintf(format_time, "%02d:%02d:%02d", day, hour, minute);
        int m = (day - 1) * 1440 + hour * 60 + minute;
        records[name].push_back({m, state, format_time});
    }
    
    for (auto & record : records) {
        string name = record.first;
        vector<Record> r = record.second;
        sort(r.begin(), r.end(), cmp);
        
        double total = 0;
        for (int i = 0; i + 1 < r.size(); i ++ ) {
            Record a = r[i], b = r[i + 1];
            if (a.state == "on-line" && b.state == "off-line") {
                if (total == 0) printf("%s %02d\n", name.c_str(), month);
                cout << a.format_time << " " << b.format_time;
                double delta = sum[b.minutes] - sum[a.minutes];
                printf(" %d $%.2f\n", b.minutes - a.minutes, delta);
                total += delta;
            }
        }
        if (total) printf("Total amount: $%.2f\n", total);
    }
    
    return 0;
}